<template>
	<view>
		<showTips :showFlag="tipShow" @tipClose='tipClose'></showTips>
		<button v-if="phoneBtn" class="phoneBtn" type="plain" open-type="getPhoneNumber"
			@getphonenumber="decryptPhoneNumber">为了您的账户安全，请点击绑定手机号码</button>
		<view class="warp">
			<view class="nav-bar">
				<view class="nav-content" v-if="!hasUserInfo">
					<view class="image-box">
						<image
							src="https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0"
							mode=""></image>
					</view>
					<view class="uesr-info">
						<view class="info-top">
							<text class="btn logon" @click="getUserProfile">立即登录</text>
						</view>
						<view class="info-bottom">
							<!-- 我的K币 ：<text style="color: orange;margin-right: 8rpx;">{{book_currency}}</text> K币 > -->
						</view>
					</view>
				</view>
				<view class="nav-content" v-else>
					<view class="image-box">
						<image :src="userInfo.avatarUrl" mode="" @click="ttgetUserInfo"></image>
						<!-- 	<image v-else
							src="https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0"
							mode=""></image> -->
						<!-- 	<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
							<image class="avatar" :src='userInfo.avatarUrl'></image>
						</button> -->

					</view>
					<view class="uesr-info">
						<view class="info-top">
							<!-- <text v-if="userInfo.nickName">{{ userInfo.nickName }}</text> -->
							<input v-model="userInfo.nickName" type="nickname" class="btn" @blur="putUser()" />
							<!-- 	<text v-else class="btn">微信用户</text> -->
							<!-- <input v-else type="nickname" class="btn" placeholder="请输入昵称" /> -->
							<!-- <image v-if="is_members == 1" class="icon-box" src="../../static/huiyuan1-01.png" mode="">
							</image> -->
							<!-- 	<image src="../../static/shuaxin.png" mode="" @click="getUserProfile"></image>
							<image src="../../static/sign.png" @click="sign"></image> -->
						</view>
						<!-- <view class="info-bottom" @click="goRecharge">
							我的K币 ：<text style="color: orange;margin-right: 8rpx;">{{book_currency}}</text> K币 >
						</view> -->
						<view class="info-bottom">
							id:{{id}}
						</view>
					</view>
				</view>
				<view>
					<!-- <van-button v-if="iosFlag == true" color="linear-gradient(to right, #FF82AB, #CD6889)" round
						size="small" @click="goCost">
						K币充值
					</van-button> -->
					<view v-if="ios_pay_switch && LinkType" @click="goCost" class="my-cost">
						K币充值
					</view>
				</view>
			</view>
			<view v-if="ios_pay_switch && LinkType">
				<view class="nav-bottom" @click="goMember" v-if="is_members == 0">
					<view class="switch">
						<image class="icon-box" src="../../static/huiyuan1-01.png" mode=""></image>
						<text class="icon-text">
							年卡会员
						</text>
					</view>
					<view class="cost">{{member_title}} >></view>
				</view>
				<view class="nav-bottom" v-else>
					<view class="switch">
						<image class="icon-box" src="../../static/huiyuan1-01.png" mode=""></image>
						<text class="icon-text">
							年卡会员
						</text>
					</view>
					<view class="cost">会员将于<text style="color: #D81E06;padding: 0 10rpx;">{{expiration_time}}到期</text> >
					</view>
				</view>
			</view>
		</view>

		<view class="my-Kcoin" v-if="LinkType">
			<view class="my-Kcoin-view">
				<view>{{book_currency}}</view>
				<text>K币余额</text>
			</view>
			<view class="my-Kcoin-view" v-if="is_members == 0">
				<view>0</view>
				<text>VIP未开通</text>
			</view>
			<view class="my-Kcoin-view" v-else>
				<view>年卡</view>
				<text>VIP</text>
			</view>
		</view>

		<view class="cate-box">
			<view class="cate-rdata" v-for="(item,index) in list1" :key="index" @click="onClick1(item)">
				<navigator url="11">
					<image class="image" :src="item.icons" mode="widthFix" />
				</navigator>
				<view class="cate-rinfo">
					<text class="cate-rtitle">
						{{item.title}}
					</text>
				</view>
				<view class="cate-rinicon">
					<image src="../../static/greater.png" mode=""></image>
				</view>
			</view>
		</view>


		<!-- <official-account bindload="load" binderror="error"></official-account> -->
		<van-popup :show="show" position="bottom" custom-style="height: auto;padding:20px 10px 4px 10px;"
			@close="onClose" :safe-area-inset-bottom="true">
			<view>
				充值K币
			</view>
			<view class="weixin-box">
				<view class="">
					<image src="../../static/weixin.png" mode=""></image>
					<text>微信充值</text>
				</view>
				<view class="">
					账户余额：<text style="color: orange;margin-right: 8rpx;">{{book_currency}}</text> K币
				</view>
			</view>
			<view class="view-list">
				<view v-for="(item,index) in cateList" :key="index" :class="{active: index === current}"
					@click="selectCate(item,index)">
					<view class="num">
						{{item.name}}
					</view>
					<view class="">
						<text>{{item.original_currency}}</text>
						<text class="tip" v-if="item.send_currency.length>0">+{{item.send_currency}}</text>
					</view>
					<view class="content">
						{{item.send_title}}
					</view>
					<view class="saleStyle" v-if="item.label.length>0">
						<text class="saleText">{{item.label}}</text>
					</view>
				</view>
				<!-- <view class="popup-bottom">
					<text>会员充值可获赠更多K币</text>
					<van-button color="linear-gradient(to right, #f7e622, #b8ae18)" round size="normal"
						@click="goDetails">
						去开通
					</van-button>
				</view> -->
			</view>
			<view class="openHuiyuan" @click="goCostSale">
				立即充值
			</view>
		</van-popup>

		<!-- 收藏 -->
		<view class="collect-zzc" v-if="collectShow"></view>
		<view class="collect-body" v-if="collectShow">
			<view>1.点击右上角菜单</view>
			<image src="../../static/collect01.jpg" mode="widthFix"></image>
			<view>2.添加到我的小程序</view>
			<image src="../../static/collect02.jpg" mode="widthFix"></image>
			<view class="collect-btn">
				<view @click="collectIsShow">我知道了</view>
			</view>
		</view>
		<!-- 开通会员 -->
		<van-popup :show="memberShow" round @close="goMember" custom-style="z-index:101;">
			<view class="Main-popup">
				<view class="popup-view">年卡会员</view>
				<view class="popup-div">
					<view class="popup-text" style="color: red;">一天仅需一元！</view>
					<view class="popup-text">年卡会员开通权益 ：</view>
					<view class="popup-text">1.全场短剧年卡会员抢先看</view>
					<view class="popup-text">2.全场短剧年卡会员免费看</view>
					<view class="popup-text">3.不限剧集，不限次数，年限为一年</view>
					<view class="popup-text">购买须知 ：因本产品为虚拟产品，购买后不退不换，不按天数计算，还请谅解。</view>
				</view>
				<view class="popupBtns">
					<!-- <text class="popup-react" @click="reactVideo">不用了</text> -->
					<text class="popup-add" @click="purchase">立即开通</text>
				</view>
			</view>
		</van-popup>

		<!-- 过期重新登录 -->
		<van-popup :show="loginShow" closeable round @close="closeloginShow" custom-style="z-index:101;">
			<view class="Main-popup">
				<view class="popup-view">重新登录</view>
				<view class="popup-div">
					<view class="popup-text">当前登录状态已过期,点击重新登录</view>
				</view>
				<view class="popupBtns">
					<text class="popup-add" @click="getUserProfile">立即登录</text>
				</view>
			</view>
		</van-popup>
	</view>
	</view>
</template>

<script>
	import {
		setWechatUserInfo,
		getBookorder,
		getBookGold,
		getMoneyList,
		login,
		sign,
		userEdit,
		ttlogin,
		appletConfig,
		getOfficialAppID
	} from '@/module/index.js'
	import showTips from '../../wxcomponents/redflower-showTips/redflower-showTips.vue'
	import {
		config
	} from '@/config/index.js'
	const app = getApp()
	export default {
		components: {
			showTips
		},
		data() {
			return {
				memberShow: false,
				tipShow: false,
				costObj: null,
				phoneBtn: true,
				iosFlag: app.globalData.iosFlag,
				is_members: 0,
				expiration_time: "--",
				book_currency: 0.00,
				member_title: '每天1元，全场免费看',
				userInfo: {},
				hasUserInfo: false,
				canIUseGetUserProfile: false,
				show: false,
				current: 0,
				collectShow: false,
				LinkType: false,
				loginShow: false,
				list1: [{
						title: "我的充值",
						icons: `../../static/shoucang.png`,
						route: '../../wxcomponents/Recharge/index'
					}, {
						title: "我的消费",
						icons: `../../static/bangzhu.png`,
						route: '../../wxcomponents/consumption/index'
					}, {
						title: "历史记录",
						icons: `../../static/history.png`,
						route: "../../wxcomponents/recordPage/recordPage"
					},
					{
						title: "投诉建议",
						icons: `../../static/meshoucang.png`,
						route: "/pages/My-self/feedback/feedback"
					},
					{
						title: "收藏小程序",
						icons: `../../static/shezhi.png`,
						route: 'collectShow'

					}
				],
				cateList: [],
				id: "",
				ios_pay_switch: true,
				annualMeeting: []
			}
		},
		onLoad(options) {
			this.renewUserInfo()
			uni.setStorageSync('login_message', {
				official_account_id: options?.official_account_id,
				uid: options?.uid,
				video_id: options?.video_id
			})
		},
		onShow() {
			this.phoneBtn = uni.getStorageSync('phoneBtn')
			this.hasUserInfo = uni.getStorageSync('token') !== '' ? true : false;
			if (this.hasUserInfo) {
				this.getBookGold()
				this.getMoneyList()
				if (uni.getStorageSync('login').user_name != this.userInfo.nickName) {
					this.renewUserInfo()
				}
				uni.getSystemInfo({
					success: res => {
						if (res.osName === 'ios') this.getAppletConfig()
					}
				})
				this.closeloginShow()
			} else {
				this.loginShow = true
			}
			this.LinkType = uni.getStorageSync('is_online')
			this.book_currency = 0.00
			this.$forceUpdate()
		},
		methods: {
			closeloginShow() {
				this.loginShow = false
			},
			getAppletConfig() {
				let data = {}
				if (uni.getStorageSync('environment') == 'official_account') {
					return
					// data.official_account_id = uni.getStorageSync('login')?.official_account_id
				} else {
					data.app_id = tt.getEnvInfoSync().microapp.appId
				}
				appletConfig(data).then((res) => {
					if (res.code === 200) {
						this.ios_pay_switch = res.data.ios_pay_switch ? true : false
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 从login中更新用户信息
			renewUserInfo() {
				let userInfo = {
					nickName: "抖音用户",
					avatarUrl: "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0"
				}
				const login = uni.getStorageSync('login')
				if (login?.user_name) {
					userInfo.nickName = login?.user_name
				}
				if (login?.avatar) {
					userInfo.avatarUrl = login?.avatar
				}
				this.userInfo = userInfo
				if (login?.id) {
					this.id = login.id
				}
			},
			// 上传头像至服务器
			upfile(data) {
				uni.uploadFile({
					url: config.base_url + 'Upload/ossUploadImage', //接口地址
					header: {
						"token": uni.getStorageSync('token'),
					}, //请求token
					filePath: data,
					name: 'file',
					success: (res) => {
						let v = JSON.parse(res.data)
						this.userInfo.avatarUrl = v.data.info.info.url
						this.putUser()
					}
				});
			},
			// 获取头像本地地址
			onChooseAvatar(e) {
				const {
					avatarUrl
				} = e.detail;
				this.upfile(avatarUrl)
			},
			// 更新用户信息
			putUser() {
				let obj = {
					user_name: this.userInfo.nickName,
					avatar: this.userInfo.avatarUrl,
					id: uni.getStorageSync('login').id
				}
				if (uni.getStorageSync('environment') == 'official_account') {
					obj.official_account_id = uni.getStorageSync('login')?.official_account_id
				} else {
					obj.app_id = tt.getEnvInfoSync().microapp.appId
				}
				userEdit(obj).then((res) => {
					if (res.code === 200) {
						this.hasUserInfo = true
						let data = uni.getStorageSync('login')
						data.user_name = this.userInfo.nickName
						data.avatar = this.userInfo.avatarUrl
						uni.setStorage({
							key: "login",
							data
						})
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 抖音 获取用户信息
			ttgetUserInfo() {
				let seft = this
				if (uni.getStorageSync('token')) {
					tt.getUserProfile({
						success(res) {
							seft.$set(seft.userInfo, "nickName", res.userInfo.nickName)
							seft.$set(seft.userInfo, "avatarUrl", res.userInfo.avatarUrl)
							seft.putUser()
						},
						fail(res) {
							console.log("getUserProfile 调用失败", res);
						},
					});
				}
			},
			decryptPhoneNumber(e) {
				if (e.detail.errMsg == "getPhoneNumber:ok") {
					this.phoneBtn = false
					uni.setStorageSync('phoneBtn', false)
				} else {
					uni.setStorageSync('phoneBtn', true)
				}
			},
			getUserProfile(e) {
				var self = this;
				let {
					official_account_id,
					uid,
					video_id,
					link_id
				} = uni.getStorageSync('login_message'); //公众号参数

				// h5登录
				if (this.isWechat()) {
					this.getCode(uni.getStorageSync('login')?.official_account_id)
					return
				}
				// 小程序
				tt.login({
					success(data) {
						ttlogin({
							code: data.code,
							official_account_id,
							uid,
							video_id,
							link_id,
							app_id: tt.getEnvInfoSync().microapp.appId
						}).then((res) => {
							if (res.code === 200) {
								uni.setStorageSync('token', res.data.token)
								uni.setStorageSync('login', res.data)
								uni.setStorageSync('is_online', (res.data.is_online_a == 1 ? false :
									true) ?? false)
								uni.setStorageSync('environment', 'applet') // 当前项目运行环境  小程序
								uni.showToast({
									title: '登录成功！',
									icon: "success"
								})
								self.closeloginShow()
								let stoTimer = setTimeout(() => {
									clearTimeout(stoTimer)
									stoTimer = null
									let login_query = uni.getStorageSync('login_query')
									let {
										path,
										query
									} = login_query
									if (path && path ===
										"wxcomponents/yjy-video-slide/yjy-video-slide") {
										if (query?.video_id) {
											uni.navigateTo({
												url: '/' + path + '?video_id=' + query
													.video_id + (
														query?.video_detail_id ?
														'&video_detail_id=' + query
														?.video_detail_id :
														'&video_detail_id=' + query
														?.video_id)
											})
										} else {
											uni.showToast({
												title: '缺少video_id参数!',
												icon: "none"
											})
											setTimeout(() => {
												uni.switchTab({
													url: '/pages/square/square'
												})
											}, 700)
										}
									} else {
										uni.switchTab({
											url: '/pages/square/square'
										})
									}
								}, 1000)
							} else {
								uni.showToast({
									title: res.message,
									icon: "none"
								})
							}
						}).catch(err => {
							console.log(err)
						})
					}
				})
			},
			isWechat() {
				return String(navigator?.userAgent?.toLowerCase()?.match(/MicroMessenger/i)) === "micromessenger";
			},
			getCode(id) {
				// 非静默授权，第一次有弹框
				let code = '';
				let callback_url = config.callback_url; // 获取页面url
				let state = this.getUrlCode().state || '';
				code = this.getUrlCode().code; // 截取code
				if (code == null || code === '') {
					// 如果没有code，则去请求
					uni.showLoading({
						title: '加载中'
					});
					getOfficialAppID({
						official_account_id: id
					}).then((res) => {
						if (res.code == 200) {
							let appid = res.data.app_id
							uni.hideLoading();
							window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(
						    callback_url
						)}&response_type=code&scope=snsapi_userinfo&state=${id}#wechat_redirect`;
						} else {
							uni.hideLoading();
							uni.showToast({
								title: res.message,
								icon: "none"
							})
						}
					}).catch((err) => {
						uni.hideLoading();
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					})
				} else {
					console.log("我的112")
					this.getUserInfo(code, state);
				}
			},
			// 从url中获取code返回
			getUrlCode() {
				// 截取url中的code方法
				var url = location.search;
				// this.winUrl = url;
				var theRequest = new Object();
				if (url.indexOf('?') != -1) {
					var str = url.substr(1);
					var strs = str.split('&');
					for (var i = 0; i < strs.length; i++) {
						theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
					}
				}
				return theRequest;
			},
			getUserInfo(code, uid) {
				let data = {
					code
				}
				uid = uid.split('_')
				data.official_account_id = uid[0] || ''
				if (uid.length > 1) {
					data.link_id = uid[1]
				}
				ttlogin(data).then((res) => {
					if (res.code == 200) {
						uni.setStorageSync('token', res.data.token)
						uni.setStorageSync('login', res.data)
						uni.setStorageSync('is_online', true) // h5下默认开启
						uni.setStorageSync('environment', 'official_account') // 当前项目运行环境  公众号网页
						app.globalData.LinkType = true
						this.closeloginShow()
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch((err) => {
					console.log(err)
				})
			},
			collectIsShow() {
				this.collectShow = !this.collectShow
			},
			onClick1(item) {
				if (item?.route == 'collectShow') {
					// this.tipShow = !this.tipShow
					this.collectIsShow()
					return
				}
				if (item?.route) {
					uni.navigateTo({
						url: item.route,
					});
				} else {
					uni.navigateTo({
						url: `/wxcomponents/myMessage/myMessage`,
					});
				}
			},
			onClick2(item) {
				if (item.title == `设置`) {
					wx.openSetting({
						withSubscriptions: true,
						success(res) {
							// res.authSetting = {
							//   "scope.userInfo": true,
							//   "scope.userLocation": true
							// }
						},
						fail(err) {
							console.log(err)
						}
					})
				} else if (item.title == `收藏小程序`) {
					this.tipShow = !this.tipShow
				} else {
					// uni.showToast({
					// 	title: '点击消息图标，进入客服会话',
					// 	icon: 'none'
					// });
				}
			},
			// 我的K币
			checkCost() {

			},
			// 我的K币
			goRecharge() {
				uni.navigateTo({
					url: `/wxcomponents/VoucherCenter/VoucherCenter`,
					fail() {
						uni.switchTab({
							url: `/wxcomponents/VoucherCenter/VoucherCenter`,
							fail() {
								uni.showToast({
									title: '敬请期待',
									icon: 'none'
								});
							}
						});
					}
				});
			},
			// 充值K币
			goCost() {
				// this.show = true
				// uni.hideTabBar()
				uni.navigateTo({
					url: `/pages/My-self/my-recharge?book_currency=${this.book_currency}&id=${this.id}`
				})
			},
			onClose() {
				this.show = false
				setTimeout(function() {
					uni.showTabBar()
				}, 500);
			},
			// 开通会员
			goMember() {
				this.memberShow = !this.memberShow
			},
			purchase() {
				if (this.annualMeeting.length == 0) {
					uni.showToast({
						title: '暂无年卡数据',
						icon: "none"
					})
					return;
				}
				let data = this.annualMeeting[0]
				let obj = {
					total_fee: data.original_currency,
					name: data.name,
					number: data.sum_currency,
					type:data.type,
					id:data.id,
					// video_id: this.video_id
				}
				getBookorder(obj).then((res) => {
					var self = this
					if (res.code === 200) {
						var record_id = res.data?.pay_record_id
						if (uni.getStorageSync('environment') == 'official_account') {
							// 公众号调起微信支付
							WeixinJSBridge.invoke(
								'getBrandWCPayRequest', {
									"appId": res.data.appId, //公众号ID，由商户传入     
									"timeStamp": res.data.timeStamp, //时间戳，自1970年以来的秒数     
									"nonceStr": res.data.nonceStr, //随机串     
									"package": res.data.package,
									"signType": "MD5", //微信签名方式：     
									"paySign": res.data.paySign //微信签名 
								},
								function(res) {
									if (res.err_msg == "get_brand_wcpay_request:ok") {
										// 使用以上方式判断前端返回,微信团队郑重提示：
										//res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
										uni.showToast({
											title: `支付成功`,
											icon: 'success'
										});
										self.memberShow = false
									} else if (res.err_msg == 'get_brand_wcpay_request:fail' || res.err_msg ==
										'get_brand_wcpay_request:cancel') {
										uni.showToast({
											title: `支付失败`,
											icon: 'none'
										});
									} else {
										uni.showToast({
											title: res.err_msg,
											icon: 'none'
										});
									}
								});
							return
						}
						uni.requestPayment({
							orderInfo: res.data.data,
							service: 5,
							success(res) {
								if (res.code == 0) {
									this.memberShow = false
									uni.showToast({
										title: `支付成功`,
										icon: 'success'
									});
								} else {
									switch (res.code) {
										case 1:
											uni.showToast({
												title: `支付超时`,
												icon: 'none'
											});
											break;
										case 2:
											uni.showToast({
												title: `支付失败`,
												icon: 'none'
											});
											break;
										case 3:
											uni.showToast({
												title: `支付关闭`,
												icon: 'none'
											});
											break;
										case 4:
											uni.showToast({
												title: `支付取消`,
												icon: 'none'
											});
											break;
										default:
											uni.showToast({
												title: `支付异常`,
												icon: 'none'
											});
									}
								}
							},
							fail(err) {
								switch (err.errMsg) {
									case 10000:
										uni.showToast({
											title: `支付失败`,
											icon: 'none'
										});
										break;
									case 10001:
										uni.showToast({
											title: `调起微信失败`,
											icon: 'none'
										});
										break;
									case 10002:
										uni.showToast({
											title: `微信未安装`,
											icon: 'none'
										});
										break;
								}
							}
						});
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				})
			},
			// 会员中心
			goDetails() {
				uni.navigateTo({
					url: `/wxcomponents/MembershipCenter/MembershipCenter`,
					fail() {
						uni.switchTab({
							url: `/wxcomponents/MembershipCenter/MembershipCenter`,
							fail() {
								uni.showToast({
									title: '敬请期待',
									icon: 'none'
								});
							}
						});
					}
				});
			},
			getBookorder(item) {
				let obj = {
					total_fee: item.recharge_price * 100,
					name: item.name,
					number: item.sum_currency
				}
				getBookorder(obj).then((res) => {
					var self = this
					if (res.code === 200) {
						var record_id = res.data.pay_record_id
						uni.requestPayment({
							timeStamp: res.data.timeStamp,
							nonceStr: res.data.nonceStr,
							package: res.data.package,
							signType: 'MD5',
							paySign: res.data.paySign,
							success(res) {
								console.log(res)
								self.show = false
								setTimeout(function() {
									self.getBookGold()
								}, 1000);
							},
							fail(err) {
								if (err.errMsg = "requestPayment:fail cancel") {
									uni.showToast({
										title: `取消支付`,
										icon: 'none'
									});
								} else {
									uni.showToast({
										title: `支付失败`,
										icon: 'none'
									});
								}
							}
						});
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getBookGold() {
				getBookGold().then((res) => {
					if (res.code === 200) {
						this.book_currency = res.data.money
						this.is_members = res.data.is_members
						this.expiration_time = res.data.expiration_time
						// this.member_title = res.data.member_title
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 微信支付
			selectCate(item, index) {
				this.current = index
				this.costObj = item
			},
			goCostSale() {
				this.getBookorder(this.cateList[this.current])
			},
			getMoneyList() {
				getMoneyList().then((res) => {
					if (res.code === 200) {
						// this.cateList = res.data
						this.annualMeeting = res.data?.filter((v) => {
							return v.type === 2
						}) || [];
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			sign() {
				let that = this;
				sign().then((res) => {
					if (res.code === 200) {
						uni.showToast({
							title: `已连续签到${res.data.sign_day}天  +${res.data.add_money}K币`,
							icon: "none",
							success: () => {
								that.getBookGold()
								that.getMoneyList()
							}

						})
					}
				})
			},
			tipClose(value) {
				this.tipShow = value
			}
		}
	}
</script>
<style>
	page {
		background-color: #ececec;
	}
</style>
<style scoped lang="scss">
	.avatar-wrapper {
		padding: 0rpx;
	}

	.phoneBtn {
		color: #fff;
		font-size: 22rpx;
		background-color: rgba(199, 109, 110, 1.1);
	}

	.warp {
		// background-color: #FFEFDB;
		background: linear-gradient(to bottom, #ececec, #ececec);
	}

	.nav-bar {
		height: 100px;
		background-color: transparent;
		padding: 20px 4px 8px;
		box-sizing: border-box;
		margin-bottom: 4px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 0 30rpx;
	}



	.nav-content {
		display: flex;
		align-items: center;
		height: 120rpx;
	}

	.nav-bottom {
		height: 100rpx;
		margin: 0 35rpx;
		margin-top: 20rpx;
		padding: 0 20rpx;
		background-color: #363636;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #fff;
		font-weight: bold;

		.icon-text {
			font-size: 31rpx;
			// letter-spacing: 6rpx;
		}
	}

	image {
		width: 60px;
		height: 60px;
		vertical-align: middle;
	}

	.switch {
		display: flex;
		align-items: center;
	}

	.icon-box {
		width: 50rpx;
		height: 55rpx;
		margin-right: 13rpx;
		margin-top: -5rpx;
		margin-left: 20rpx;
	}

	.cost {
		font-size: 24rpx;
		color: #ffe09e;
		font-weight: 600;
	}

	.my-cost {
		font-size: 28rpx;
		color: #FFFFFF;
		padding: 20rpx 55rpx;
		border-radius: 60rpx;
		font-weight: 600;
		background: linear-gradient(to bottom, #FF6347, #8B0000);
		letter-spacing: 3rpx;
	}



	.image-box {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
		overflow: hidden;
		border: 6rpx solid #FFFFFF;
	}

	.image-box>button>image {
		// width: 70px;
		// height: 70px;
		vertical-align: middle;
	}

	.image-box>image {
		// width: 70px;
		// height: 70px;
		vertical-align: middle;
	}


	.uesr-info {
		height: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		margin-left: 8px;
	}

	.uesr-info image {
		width: 45rpx;
		height: 45rpx;
		vertical-align: top;
		margin-left: 10rpx;
	}

	.info-top {
		font-size: 16px;
		font-weight: 600;
		color: #000000;
		margin-bottom: -30rpx;
	}

	.logon {
		position: relative;
		top: 15rpx;
		padding: 20rpx;
	}

	.info-bottom {
		font-size: 23rpx;
		color: #999aaa;
	}

	.info-bottom button {
		font-size: 12px;
		background-color: unset;
		border: unset;
	}

	.btn {
		color: #000000;
		width: 260rpx;
	}

	.view-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-around;
	}

	.view-list>.active {
		border: 1px solid #D9D9D9;
		background-color: #e21f0d;
		opacity: 0.8;
		color: #fff;
	}

	.view-list:after {
		display: block;
		content: "";
		width: 44%;
		height: 0px;
	}

	.view-list>view {
		width: 44%;
		padding: 10rpx 0rpx;
		border: 1px solid #d9d9d9;
		text-align: center;
		margin: 20rpx 0rpx;
		position: relative;
		overflow: hidden;
	}

	.saleStyle {
		position: absolute;
		top: 0rpx;
		right: -78rpx;
		width: 0rpx;
		height: 0rpx;
		border: 76rpx solid #000;
		border-color: #000000 transparent transparent transparent;
		color: #FFFFFF;
	}

	.saleText {
		position: absolute;
		top: -68rpx;
		right: -2rpx;
		font-size: 20rpx;
		width: 30px;
		transform: rotate(45deg);
	}

	.weixin-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.view-list>.popup-bottom {
		background-color: #808080;
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		padding: 0px 20rpx;
	}

	.tip {
		color: #df851d;
	}

	.num {
		/* font-size: 40rpx;
		font-weight: 900; */
	}

	.content {
		color: #df851d;
		font-size: 30rpx;
	}

	.contact-icon {
		margin-left: 25rpx;
	}

	.cate-rdata {
		display: flex;
		padding: 10rpx 20rpx;
		// color: #666666;
		margin: 20rpx 0;
		// font-size: 30rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		font-weight: 600;
	}

	.cate-rinicon {
		>image {
			width: 20rpx;
			height: 30rpx;
		}
	}

	.my-Kcoin {
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 40rpx 35rpx;
	}

	.my-Kcoin-view {
		width: 50%;
		text-align: center;

		>view {
			font-weight: 800;
		}

		>text {
			font-size: 24rpx;
			color: #999aaa;
		}
	}

	.cate-rinfo {
		flex: 1;
		margin-left: 20rpx;
		padding-bottom: 20rpx;
		// border-bottom: 1px solid #eee;
		min-width: 1px;
	}

	.cate-rbtn {}

	.cate-rinfo button {
		display: flex;
		align-items: center;
		background-color: #FFFFFF;
		font-size: 30rpx;
		color: #666666;
		text-align: left;
		padding: 0;
		border: none;
		height: 40rpx;
	}

	.cate-rinfo button::after {
		border: none;
	}

	.cate-rfooter {
		display: flex;
		align-items: center;
	}

	.cate-rnum {
		flex: 1;
	}

	.image {
		width: 40rpx;
		height: 40rpx;
		vertical-align: top;
	}

	.cate-box {

		margin: 20rpx 35rpx;
		background-color: #FFFFFF;
		// box-sizing: border-box;
		padding: 30rpx 20rpx;
		border-radius: 20rpx;
	}

	// .cate-box>.cate-rdata:nth-child(3) .cate-rinfo {
	// 	border: none;
	// }

	.openHuiyuan {
		text-align: center;
		color: #FFFFFF;
		background-color: #F25011;
		margin-top: 20rpx;
		height: 100rpx;
		line-height: 100rpx;
	}

	.collect-zzc {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		background-color: rgba(0, 0, 0, 0.6);
		z-index: 100;
	}

	.collect-body {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 101;
		text-align: center;
	}

	.collect-body>view {
		color: #ffffff;
		letter-spacing: 2rpx;
		font-weight: 600;
		margin: 60rpx 0;
	}

	.collect-body>image {
		width: 90%;
	}

	.collect-btn {
		width: 100%;
		text-align: center;
	}

	.collect-btn>view {
		width: 200rpx;
		padding: 20rpx 30rpx;
		border: 2rpx solid #ffffff;
		border-radius: 20rpx;
		margin: auto;
	}


	.Main-popup {
		padding: 30rpx 40rpx;
		width: 500rpx;
		// text-align: center;
		// line-height: 80rpx;
	}

	.popup-div {
		background-color: #F5F5F5;
		padding: 30rpx;
		border-radius: 15rpx;
	}

	.popup-add {
		display: inline-block;
		width: 200rpx;
		height: 60rpx;
		padding: 5rpx 10rpx;
		line-height: 60rpx;
		background-color: #d81e06;
		border-radius: 20rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		font-weight: 400;
		text-align: center;
		margin-left: 8rpx;
	}

	.popup-react {
		display: inline-block;
		width: 200rpx;
		height: 60rpx;
		line-height: 60rpx;
		background-color: #ffffff;
		border-radius: 30rpx;
		color: #c8c8c8;
		font-size: 30rpx;
		font-weight: 400;
		text-align: center;
		border: 1px solid #EAEAEA;
	}

	.popup-view {
		text-align: center;
		font-weight: 600;
		color: #000000;
		margin: 15rpx 0;
		font-size: 34rpx
	}

	.popup-text {
		font-size: 26rpx;
		font-weight: 600;
		margin: 10rpx 0;
	}

	.popup-btn {
		display: inline-block;
		width: 110px;
		height: 60rpx;
		line-height: 60rpx;
		background-color: #DF851D;
		border-radius: 30rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		font-weight: 400;
		text-align: center;
		// margin-bottom: 20rpx;
	}

	.popupBtns {
		margin: 35rpx 0 20rpx 0;
		text-align: center;
	}
</style>